.class public Lcom/baidu/mobads/utils/b;
.super Ljava/lang/Object;
.source "SourceFile"


# direct methods
.method public static a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 10

    .line 1
    invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    const-string v1, ""

    if-nez v0, :cond_3

    invoke-static {p0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-eqz v0, :cond_0

    goto :goto_2

    :cond_0
    :try_start_0
    const-string v0, "RSA/ECB/PKCS1PADDING"

    .line 2
    invoke-static {v0}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;)Ljavax/crypto/Cipher;

    move-result-object v0

    .line 3
    invoke-static {p0}, Lcom/baidu/mobads/utils/b;->a(Ljava/lang/String;)Ljava/security/PublicKey;

    move-result-object p0

    check-cast p0, Ljava/security/interfaces/RSAPublicKey;

    const/4 v2, 0x1

    .line 4
    invoke-virtual {v0, v2, p0}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;)V

    const-string v3, "UTF-8"

    .line 5
    invoke-virtual {p1, v3}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object p1

    .line 6
    invoke-interface {p0}, Ljava/security/interfaces/RSAPublicKey;->getModulus()Ljava/math/BigInteger;

    move-result-object p0

    invoke-virtual {p0}, Ljava/math/BigInteger;->bitLength()I

    move-result p0

    const/16 v3, 0x8

    div-int/2addr p0, v3

    .line 7
    array-length v4, p1

    .line 8
    new-instance v5, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v5}, Ljava/io/ByteArrayOutputStream;-><init>()V

    const/4 v6, 0x0

    const/4 v7, 0x0

    const/4 v8, 0x0

    :goto_0
    sub-int v9, v4, v7

    if-lez v9, :cond_2

    if-le v9, p0, :cond_1

    .line 9
    invoke-virtual {v0, p1, v7, p0}, Ljavax/crypto/Cipher;->doFinal([BII)[B

    move-result-object v7

    goto :goto_1

    .line 10
    :cond_1
    invoke-virtual {v0, p1, v7, v9}, Ljavax/crypto/Cipher;->doFinal([BII)[B

    move-result-object v7

    .line 11
    :goto_1
    array-length v9, v7

    invoke-virtual {v5, v7, v6, v9}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    add-int/2addr v8, v2

    mul-int v7, v8, p0

    goto :goto_0

    .line 12
    :cond_2
    invoke-virtual {v5}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object p0

    .line 13
    invoke-virtual {v5}, Ljava/io/ByteArrayOutputStream;->close()V

    .line 14
    invoke-static {p0, v3}, Landroid/util/Base64;->encodeToString([BI)Ljava/lang/String;

    move-result-object p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    return-object p0

    :catchall_0
    move-exception p0

    .line 15
    invoke-static {}, Lcom/baidu/mobads/utils/q;->a()Lcom/baidu/mobads/utils/q;

    move-result-object p1

    invoke-virtual {p1, p0}, Lcom/baidu/mobads/utils/q;->d(Ljava/lang/Throwable;)I

    :cond_3
    :goto_2
    return-object v1
.end method

.method private static a(Ljava/lang/String;)Ljava/security/PublicKey;
    .locals 2

    const/4 v0, 0x2

    .line 16
    :try_start_0
    invoke-static {p0, v0}, Landroid/util/Base64;->decode(Ljava/lang/String;I)[B

    move-result-object p0

    const-string v0, "RSA"

    .line 17
    invoke-static {v0}, Ljava/security/KeyFactory;->getInstance(Ljava/lang/String;)Ljava/security/KeyFactory;

    move-result-object v0

    .line 18
    new-instance v1, Ljava/security/spec/X509EncodedKeySpec;

    invoke-direct {v1, p0}, Ljava/security/spec/X509EncodedKeySpec;-><init>([B)V

    .line 19
    invoke-virtual {v0, v1}, Ljava/security/KeyFactory;->generatePublic(Ljava/security/spec/KeySpec;)Ljava/security/PublicKey;

    move-result-object p0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    return-object p0

    :catchall_0
    move-exception p0

    .line 20
    invoke-static {}, Lcom/baidu/mobads/utils/q;->a()Lcom/baidu/mobads/utils/q;

    move-result-object v0

    invoke-virtual {v0, p0}, Lcom/baidu/mobads/utils/q;->d(Ljava/lang/Throwable;)I

    const/4 p0, 0x0

    return-object p0
.end method
